home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’93
/
Hellcats FlightRecorder
/
SaveFrame.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-18
|
2KB
|
88 lines
#include "FlightRecorder.h"
Boolean IsPressed(unsigned short k, unsigned char km[16])
{
return ((km[k>>3] >> (k & 7)) & 1);
}
//
// save one frame of animation out to the PICS movie file
//
void SaveAFrame(storage *s)
{
unsigned char keys[16];
GetKeys((void*)keys);
if(IsPressed(0x31,keys)) {
/* unpatch get next event */
SetToolTrapAddress( s->gneLink, _GetNextEvent);
HPurge(s->code);
CloseResFile(s->ref);
} else {
PicHandle pict;
WindowPtr fWind;
GrafPtr savePort;
short saveRef;
OSErr err;
GetPort(&savePort);
fWind = FrontWindow();
if(!fWind) return;
/* make sure the window is the current port */
SetPort(fWind);
pict = OpenPicture(&fWind->portRect);
/* copy the window onto itself to record it */
/* no drawing actually occurs since O.P. calls hide pen */
CopyBits( &fWind->portBits,
&fWind->portBits,
&fWind->portRect,
&fWind->portRect,
srcCopy,
nil);
ClosePicture();
if( !(**pict).picSize ) {
DebugStr("\p Picture is messed up");
}
SetPort(savePort);
/* save resource chain */
saveRef = CurResFile();
/* make our PICS file first */
UseResFile(s->ref);
/* add our resource to it */
AddResource( (Handle)pict, 'PICT', s->fCount, "\p");
if(err = ResError()) {
DebugStr("\p AddResource failed");
}
WriteResource( (Handle)pict );
if(err = ResError()) {
DebugStr("\p WriteResource failed");
}
ReleaseResource( (Handle)pict );
if(err = ResError()) {
DebugStr("\p RelaseResource failed");
}
UpdateResFile(s->ref);
/* restore resource chain */
UseResFile(saveRef);
s->fCount++;
}
}